package poswar.contribute.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import poswar.contribute.mbean.UserBean;
import poswar.contribute.util.FacesUtils;

@FacesValidator("instructorExclusiveValidator")
public class InstructorExclusiveValidator implements Validator {

	public void validate(FacesContext context, UIComponent arg1, Object arg2)
			throws ValidatorException {
		UserBean userBean = FacesUtils.findBean("userBean");
		if (!userBean.isInstructor()) {
			FacesMessage message = new FacesMessage(
					"Instructor exclusive function!");
			throw new ValidatorException(message);
		}
	}

}
